﻿<?php
@session_start();

/*   Description  of this file
*    Author king-of-war
*    Last Modified 2009-4-8
*    This class designed  for the news delete
*/
$root_path = '../';
 error_reporting(E_ALL^E_NOTICE); //去除变量为空错误
include_once $root_path . 'admin/smarty_config.php';
include_once $root_path . 'admin/class/news.class.php';
$demo = new news($root_path);

include_once $root_path . 'admin/class/fun_common.php';
$fun = new fun_common($root_path);
$max = $fun->getAll('news', 1);

/*
 *
 * check identify
 */
include_once $root_path.'admin/class/verify.class.php';
$a=new verify($root_path);
$a->identity_check(3);




/*
 * page moudle start
 *
 */
 include_once $root_path . 'admin/class/cfg.class.php';
$cfg=new cfg($root_path);
  $page_size=$cfg->xml_read('page_num');
if (!empty ($_GET['p'])) {
	$page = $_GET['p'];
} else {
	$page = 1;
}
$pages = $fun->page($page,$page_size, $max);
/*
 * page moulde  end
 *  news_get($arr,1) $arr mean range ; 1means admin
 */
$arr[0] = $pages['start'];
$arr[1] = $page_size;
$pass = $demo->news_get($arr, 0);
$max = count($pass);
$news = array ();
for ($i = 0; $i < $max; $i++) {
	$news[$i]['id'] = $pass[$i]->get_id();
	$news[$i]['title'] = $pass[$i]->get_title();
	$news[$i]['images'] = $pass[$i]->get_images();
  $news[$i]['comments'] = $pass[$i]->get_comments();
	$news[$i]['author'] = $pass[$i]->get_author();
	$news[$i]['date'] = $pass[$i]->get_date();
	$news[$i]['verify'] = $pass[$i]->get_verify();
}
/*
 * news get end
 */
/*
 * new delete start
 */
if (isset($_POST['Submit'])) {

//	$ids = array ();
		$t=0;
	for ($i = 0; $i < $max; $i++) {
		$id = $news[$i]['id'];

		if ($_POST[$id]!= '') {

			$ids[$t]=$id;
			$t++;
		}

	}

	 $line=$demo->news_del($ids);


if($line){
	echo '<div align="center"><h1>成功删除'.$line.'条新闻</h1></div>';
}else{
	echo '<div align="center"><h1>删除失败</h1></div>';
};
}
$smarty->assign("news", $news);
$smarty->assign("page", $pages);
$smarty->assign("url", $root_path);
$smarty->display("news_del.html");
?>
